package com.woniu.supermarket.web;

import com.woniu.supermarket.result.ResultResponse;
import com.woniu.supermarket.service.IPurchaseReturnDetailService;
import com.woniu.supermarket.vo.PurchaseReturnDetailVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("PurchaseReturnDetail")
@Api(value = "订单详情操作")
public class PurchaseReturnDetailController {

    @Autowired
    IPurchaseReturnDetailService iPurchaseReturnDetailService;

    @GetMapping("/showPurchaseReturnDetail/{returnNumber}")
    @ApiOperation(value = "根据采购退货订单查询详情信息")
    public ResultResponse<List<PurchaseReturnDetailVo>> showPurchaseReturnDetail(@PathVariable("returnNumber")String returnNumber){
        ResultResponse<List<PurchaseReturnDetailVo>> result = null;
        try {
            List<PurchaseReturnDetailVo> lists = iPurchaseReturnDetailService.findByPurchaseReturnCode(returnNumber);
            result = new ResultResponse<>(200,"查询退货订单成功",lists);
        }catch (RuntimeException e){
            e.printStackTrace();
            result = new ResultResponse<>(201,"查询退货订单详情失败");
        }
        return result;
    }
}
